/**
 * Created by acer on 2015/3/19.
 */
var appSocket='..';

function ajaxRequest(params,CallBack){
    alert(params)
    params=JSON.parse(params)
    $.ajax({
        url:params.url,
        contentType: "application/json",
        data:JSON.stringify(params.data),
        "Content-Type":"utf-8",
        type:'POST',
        async:true,
        dataType:"JSON",
        success:CallBack,
        error:function(err){
            alert(JSON.stringify(err));
        }
    });
}

function uploadAjax(url,data,callback) {
    $.ajax({
        url:url,
        data:data,
        type:'POST',
        contentType: false,
        processData: false
    }).then(
        callback,
        function(err){
            //alert("ajaxError:"+JSON.stringify(err))
        }
    );
}

$(document).ready(function(){
    $('.summernote').summernote();
    $('#showCollectionTable >li').bind('click',function(){

    })
    try{    $('.timeAccurate').datetimepicker({
        minView:'0',
        format: 'yyyy-mm-dd hh:ii:ss',
        pickTime: false,
        autoclose:true,
        language:"zh-CN",
        todayBtn:  1
    });
    }
    catch(err){
        console.log(222)
    }
    $('#side-menu li:nth-child(2)').find('ul li:nth-child(6)').children('a').text('评标结果公示')
})

function paging(listdata){
    var topage=toPage;
    /*分页判断start*/
    pagesnum=listdata;/*总页数*/
    var pages = [];
    if(topage>=3&&(pagesnum-topage)>=3){
        var str=[];
        var spage = topage-3;
        for(var i=1;i<=5;i++){
            str[i-1]={page:spage+i}
        }
        pages = {currentpage:topage,pages:str};
        return pages;
    }else if(topage<3&&(pagesnum-topage)<3){
        var str=[];
        for(var i=1;i<=pagesnum;i++){
            str[i-1]={page:i}
        }
        pages = {currentpage:topage,pages:str};
        return pages;
    }else if(topage>=3&&(pagesnum-topage)<3){
        if(topage<=4){
            var str=[];
            for(var i=1;i<=pagesnum;i++){
                str[i-1]={page:i}
            }
            pages = {currentpage:topage,pages:str};
        }else{
            var str=[];
            var spage = pagesnum-5;
            for(var i=1;i<=5;i++){
                str[i-1]={page:spage+i}
            }
            pages = {currentpage:topage,pages:str};
        }
        return pages;
    }else if(topage<3&&(pagesnum-topage)>=3){
        var str=[];
        var j;
        if(pagesnum<=5){
            j=pagesnum;
        }else{
            j=5;
        }
        for(var i=1;i<=j;i++){
            str[i-1]={page:i}
        }
        pages = {currentpage:topage,pages:str};
    }
    return pages;
    /*分页判断end*/
}

 selectInner=function(Type){
     var insertHtml=new Array()
     var provinceArray=["河北","山西","内蒙古","辽宁","吉林","黑龙江","江苏","浙江","安徽","福建","江西","山东","河南","湖北","湖南","广东","广西","海南","四川","贵州","云南","西藏","陕西","甘肃","青海","宁夏","新疆","香港","澳门","台湾"];
     var cityArray=["福州市","南平市","莆田市","三明市","泉州市","厦门市","漳州市","龙岩市","宁德市"]
     var areaCommon=[["鼓楼区","台江区","仓山区","马尾区","晋安区","福清市","长乐市","闽侯县","连江县","凤城镇","罗源县","凤山镇","闽清县","梅城镇","永泰县","樟城镇","平潭县","潭城镇"],["延平区","邵武市","武夷山市","建瓯市","建阳市","顺昌县","浦城县","光泽县","杭川镇","松溪县","松源镇","政和县","熊山镇"],["城厢区","涵江区","荔城区","秀屿区","仙游县"],["梅列区","三元区","永安市","明溪县","雪峰镇","清流县","龙津镇","宁化县","翠江镇","大田县","均溪镇","尤溪县","城关镇","沙县","将乐县","古镛镇","泰宁县","杉城镇","建宁县","濉城镇"],["鲤城区","丰泽区","洛江区","泉港区","石狮市","晋江市","南安市","惠安县","螺城镇","安溪县","凤城镇","永春县","桃城镇","德化县","浔中镇","金门县"],["思明区","海沧区","湖里区","集美区","同安区","翔安区"],["芗城区","龙文区","龙海市","云霄县","云陵镇","漳浦县","绥安镇","诏安县","南诏镇","长泰县","武安镇","东山县","西埔镇","南靖县","山城镇","平和县","小溪镇","华安县","华丰镇"],["新罗区","漳平市","长汀县","汀州镇","永定县","凤城镇","上杭县","临江镇","武平县","平川镇","连城县","莲峰镇"],["蕉城区","福安市","福鼎市","寿宁县","鳌阳镇","霞浦县","柘荣县","双城镇","屏南县","古峰镇","古田县","周宁县","狮城镇"]]
    for(var i in cityArray){
    if(Type==cityArray[i]){
        for(var j in areaCommon[i]){
            insertHtml.push('<option>'+areaCommon[i][j]+'</option>'+'</br>')
        }
    }
    }
     if(Type=='All'){
         for(var k in cityArray)
         insertHtml.push('<option>'+cityArray[k]+'</option>'+'</br>')
     }
     if(Type=='province'){
         for(var l in provinceArray)
             insertHtml.push('<option>'+provinceArray[l]+'</option>'+'</br>')
     }

     return insertHtml
}

convertTime = function(time){
    time=time.substr(0,10)+' '+time.substr(11,5)
    return time
}
Date.prototype.Format = function(fmt){
    var o = {
        "M+" : this.getMonth()+1,                 //月份
        "d+" : this.getDate(),                    //日
        "h+" : this.getHours(),                   //小时
        "m+" : this.getMinutes(),                 //分
        "s+" : this.getSeconds(),                 //秒
        "q+" : Math.floor((this.getMonth()+3)/3), //季度
        "S"  : this.getMilliseconds()             //毫秒
    };
    if(/(y+)/.test(fmt))
        fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
    for(var k in o)
        if(new RegExp("("+ k +")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
    return fmt;
};

function ats(l){
    alert(JSON.stringify(l))
}
